#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;

int count_letters(int num) {
    static map<int, string> m {
        {0, ""},
        {1, "one"},
        {2, "two"},
        {3, "three"},
        {4, "four"},
        {5, "five"},
        {6, "six"},
        {7, "seven"},
        {8, "eight"},
        {9, "nine"},
        {10, "ten"},
        {11, "eleven"},
        {12, "twelve"},
        {13, "thirteen"},
        {14, "fourteen"},
        {15, "fifteen"},
        {16, "sixteen"},
        {17, "seventeen"},
        {18, "eighteen"},
        {19, "nineteen"},
        {20, "twenty"},
        {30, "thirty"},
        {40, "forty"},
        {50, "fifty"},
        {60, "sixty"},
        {70, "seventy"},
        {80, "eighty"},
        {90, "ninety",},
        {100, "hundred"},
        {1000, "thousand"},
    };

    int d = num % 10;
    int c = (num / 10) % 10;
    int b = (num / 100) % 10;
    int a = num / 1000;
    int r = 0;
    if (a > 0) {
        r += m[a].size() + m[1000].size();
        cout << m[a] << ' ' << m[1000] << ' ';
    }
    if (b > 0) {
        r += m[b].size() + m[100].size();
        cout << m[b] << ' ' << m[100] <<  ' ';
    }
    if (c > 0) {
        if (a > 0 || b > 0) {
            r += 3; // "and"
            cout << "and ";
        }
        if (c == 1) {
            r += m[c * 10 + d].size();
            cout << m[c * 10 + d] << ' ';
        } else {
            r += m[c * 10].size() + m[d].size();
            cout << m[c * 10] << ' ' << m[d] << ' ';
        }
    } else {
        if ((d > 0) && (a > 0 || b > 0)) {
            r += 3; // "and"
            cout << "and ";
        }
        r += m[d].size();
        cout << m[d];
    }
    cout << endl;
    return r;
}
    
int main() {
    int sum = 0;
    for (int i = 1; i <= 1000; i++) {
        sum += count_letters(i);
    }
    cout << sum << endl;
    return 0; // 20881
}
    